import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-menu-list',
  templateUrl: './menu-list.component.html',
  styleUrls: ['./menu-list.component.scss']
})
export class MenuListComponent implements OnInit {
  @Input() parentId:string;
  private session = sessionStorage;
  public meanList = [
    {icon: 'clue-icon', link: 'home/clue', name: '线索管理', flag: false},
    {icon: 'handle-icon', link: 'home/handle', name: '案件办理', flag: false},
    {icon: 'approval-icon', link: 'home/approval', name: '案件审批', flag: false},
    {icon: 'settings-icon', link: 'home/settings', name: '系统设置', flag: false},
    {icon: 'charts-icon', link: 'home/charts', name: '统计图表', flag: false},
  ];
  constructor() {}

  ngOnInit() {
    this.session.setItem('approval', 'false');
    let resourceInfo = JSON.parse(this.session.getItem('resources'));
    let roleInfo = JSON.parse(this.session.getItem('roles'));
    for(let i = 0; i < resourceInfo.length; i++) {
      let href = resourceInfo[i]['resourcePermission'];
      for(let j = 0; j < this.meanList.length; j++) {
        if (this.meanList[j]['link'] == href) {
          this.meanList[j]['flag'] = true;
        }
      }
    }
    for(let k = 0; k < roleInfo.length; k++) {
      if (roleInfo[k]['roleName'] == '审批人员') {
        this.session.setItem('approval', 'true');
      }
    }
  }

}
